﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using Osobe;
using SkolskaUstanova;
using MolbeIPotvrde;

namespace ElektronskiDnevnik
{
    public partial class PodnosenjeZahtjeva : Form
    {
        MySqlConnection conn;
        String podnosilac, ucenik;
        public PodnosenjeZahtjeva(String p, String u, MySqlConnection c)
        {
            InitializeComponent();
            conn = c;
            podnosilac = p;
            ucenik = u;
            brojac++;
        }

        private void button6_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked == false && radioButton2.Checked == false)
                MessageBox.Show("Morate odabrati tip zahtjeva", "Upozorenje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            else if (textBox1.Text == "")
                MessageBox.Show("Morate upisati svrhu molbe", "Upozorenje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            else
            {
                MySqlCommand cmd; 
                int tip, rjesenje;
                rjesenje = 1;
                if (radioButton1.Checked)
                    tip = 1;
                else
                    tip = 2;
                cmd = new MySqlCommand("INSERT INTO PotvrdaMolba (" + "BrojProtokola, Datum, Tip, Rijesenje, Svrha, Ucenik, Podnosioc" +") VALUES('" + Convert.ToString((Convert.ToDateTime(dateTimePicker1.Text)).Day) + Convert.ToString((Convert.ToDateTime(dateTimePicker1.Text).Month)) + "/" + Convert.ToString((Convert.ToDateTime(dateTimePicker1.Text)).Year) + "', '" + Convert.ToString((Convert.ToDateTime(dateTimePicker1.Text)).Year) + "-" + Convert.ToString((Convert.ToDateTime(dateTimePicker1.Text)).Month) + "-"+ Convert.ToString((Convert.ToDateTime(dateTimePicker1.Text)).Day) + "', "+ tip + ", " + rjesenje + ", '" + textBox1.Text + "', '" + ucenik + "', '" + podnosilac + "');", conn);
                cmd.ExecuteNonQuery();
                
                richTextBox1.Visible = true;
            }
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            richTextBox1.Visible = false;
            textBox1.Text = "Potvrda o redovnom skolovanju";
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            richTextBox1.Visible = false;
            textBox1.Text = "";
        }

        private void Form13_Load(object sender, EventArgs e)
        {
            radioButton1.Checked = false;
            radioButton1.Checked = false;
            richTextBox1.Visible = false;
        }
    }
}
